<!DOCTYPE html>
<html>

<head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       <title></title>
       <link href="/styles/base.css" rel="stylesheet" type="text/css">
       <link href="/styles/addtravelnote.css" rel="stylesheet" type="text/css">
       <link href="/styles/wendas.css" rel="stylesheet" type="text/css">
       <link href="/js/ueditor/themes/default/css/umeditor.css" type="text/css" rel="stylesheet">
       <link href="/js/plugins/datepicker/datepicker.css" rel="stylesheet">
       <script type="text/javascript" src="/js/jquery/jquery.js"></script>
       <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.config.js"></script>
       <script type="text/javascript" charset="utf-8" src="/js/ueditor/umeditor.min.js"></script>
       <script type="text/javascript" src="/js/ueditor/lang/zh-cn/zh-cn.js"></script>
       <script src="/js/plugins/datepicker/datepicker.js"></script>
       <script src="/js/plugins/jquery-form/jquery.form.js"></script>

       <link href="/js/plugins/chosen/chosen.css" rel="stylesheet" type="text/css">
       <script type="text/javascript" src="/js/plugins/chosen/chosen.jquery.js"></script>
       <script type="text/javascript" src="/js/system/common.js"></script>
       <script type="text/javascript" src="/js/system/addtravelnote.js"></script>
       <script>
           $(function () {content:
               $(".chose_pic").click(function () {
                   $("#coverBtn").click();
               })
               $("#coverBtn").change(function () {
                   if(this.value){
                       $("#coverForm").ajaxSubmit(function (data) {
                           $(".choseBtn").html(" + 重新选择");
                           $("#coverImage").attr("src", "/" +data);
                           $("#coverValue").val("/" + data);
                       })
                   }
               })

               //保存或发表
               $(".btn_submit, .btn_save").click(function () {
                   /*var labels = [];
                   $('.pi-tagitem span').each(function (index, value) {
                       labels.push($(value).text());
                   })

                   $("#tagInput").val(labels.join(","))*/
                   $("#state").val($(this).data("state"));
                   $("#editForm").ajaxSubmit(function (data) {
                       if(data.success){
                           window.location.href = "/travel/detail?id=" + data.data
                       }else{
                           popup("操作失败");
                       }
                   })
               })

               //目的地
               $("#region").chosen();


               //内容回显
               if('${tv!}'){
                   ue.setContent('${(tv.content)!}');
               }
           })


       </script>
</head>

<script>
    $(function () {
        //游记分页
        $(".com-opt").change(function () {
            $("#currentPage").val(1);
            $("#searchForm").submit();
        })
        $(".orderBy").click(function () {
            $(".orderBy").closest("div").removeClass("on");
            $(this).addClass("on");
            $("#currentPage").val(1);
            $("#orderType").val($(this).data("sort"))
            $("#searchForm").submit();
        })
    })
    $(function () {
        $(".btn-inputTravel").click(function () {
            var user = this.getAttribute("data-userInfo");
            console.log(user);
            if( user != null && user != ""){
                this.setAttribute("href","/travel/input")
            }else{
                alert("请您先登录后在执行此操作。");
            }
        })

        $(".btn-ding").click(function () {
            var travelId = this.getAttribute("data-id");
            var span = $(this).prev();
            $.get("/travel/travelThumbup",{travelId:travelId},function (data) {
                if(data.success){
                    $(span).html(data.data);
                    popup("顶成功啦");

                }else{
                    if(data.code == 102){
                        popup(data.msg);
                    }else{
                        popup("今天你已经顶过了");
                    }
                }
            })
        })
    })

    $(function () {
        $(".btn-sub").click(function () {
            $("#editForm1").ajaxSubmit(function (data) {
                console.log(data);
                if(data.success){
                    console.log(data.data);
                    window.location.href = "/wenda/detail?id=" + data.data
                }
            })
        })
    })

</script>

<body>
    <#assign currentNav="travel">
    <#include "../common/navbar.ftl">

    <!--文件上传-->
    <form action="/wenda/coverImageUpload" method="post" id="coverForm">
        <input type="file" name="pic" id="coverBtn" style="display: none;">
    </form>
    <div class="wrapper">
        <div class="crumb">
            <a href="/wenda/">旅游问答</a> &gt; <span>我要提问</span>
        </div>
        <div class="ap-wrap">
                <form class="forms" action="/wenda/saveOrUpdate" method="post" id="editForm1">
                    <div class="qt-tit">
                        <h5>问题标题</h5>
                        <div class="qt-con">
                            <input type="text" placeholder="标题不小于10字哦" class="_j_title" name="title">
                        </div>
                    </div>
                    <div class="qt-details" id="_qa_detail" style="margin-top: 20px;">
                        <h5>问题详细内容</h5>
                    </div>


                    <dl class="body cf">
                        <dd id="content_div" >
                            <script id="editor" type="text/plain" style="width:68%;height:300px;"></script>
                        </dd>
                    </dl>
                                <div><input type="hidden"></div>

                        <div class="qt-mdd _qa_block" id="_qa_mdd" style="margin-top: 20px;">
                                <h5>选择目的地</h5>
                                <select name="dest.id" data-placeholder="请选择目的地" id="region" style="width: 150px;">
                               <#list dests as s>
                                    <option value="${s.id!}">${s.name!}</option>
                                </#list>
                                </select>
                        </div>
                        <div class="qt-interest _qa_block" id="_qa_interest" style="margin-top: 20px;">
                            <h5>选择兴趣标签</h5>
                            <div class="qt-con _j_interest_list">
                                <dl class="interest-description" style="width: 65%;">
                                    <dt><i></i><span>什么是兴趣标签</span></dt>
                                    <dd>兴趣标签是一个问题的类型，它有助于为你的问题匹配擅长该类问题的蜂蜂回答。目前仅开放了以下几个话题，更多类型我们会逐步开放。</dd>
                                </dl>
                                <div class="interest-tags" style="width:650px;">
                                    <#list tags as t>
                                    <a class="btn-interest _j_interest btn_tags" style="background-color:;" data-id="${t.id}" name="tag"><i></i>#${t.name}</a>
                                    </#list>
                                </div>
                                <input class="btn_tag" type="hidden" name="atags" >
                                <script>
                                    $(function () {
                                        var flag = true;
                                        var tags;
                                        $(".btn_tags").click(function () {
                                            if(flag){
                                                $(this).css("background-color","orange");
                                                console.log(this.getAttribute("data-id"));
                                                if(this.getAttribute("data-id") +"" != undefined){
                                                    tags +=this.getAttribute("data-id") +",";
                                                }
                                                $(".btn_tag").val(tags);
                                                flag = false;
                                            }else{
                                                $(this).css("background-color","");
                                                flag = true;
                                            }
                                        });
                                    })
                                </script>
                            </div>
                        </div>
                </div>
                <div class="qt-notice" style="margin-top: -30px;">
                    <input type="checkbox" class="checkbox _j_anonymous" name="anonymity">
                    <p>匿名提问（其他用户将不会在你的窝里看到这个问题）</p>
                </div>
                <div class="publish_question" style="margin-top: 20px">
                    <button type="button" class="qt-post-btn _j_publish btn-sub"  title="发布问题">发布问题</button>
                </div>
                </form>
             </div>
          </div>
   <#include "../common/footer.ftl">
  </body>

</html>